package com.xdclass.guard;

import java.util.function.Predicate;

/**
 * @Author: Timo
 * @Date: 2019/4/26 14:41
 * @Description: 守护线程DEMO
 */
public class GuardDemo1 implements Runnable{


    @Override
    public void run() {
        while (true) {
            System.out.println(Thread.currentThread().getName());
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }


    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new GuardDemo1());
        t.start();
        // 设置为守护线程
        t.setDaemon(true);
        Thread.sleep(2000L);
    }
}
